<?php
namespace app\console\validate;

use think\Validate;

class Manage extends Validate
{
    protected $rule = [
        ['avatar', 'require'],
        ['username', 'require|length:6,18|unique:manage'],
        ['password', 'require|length:6,18',],
        ['confirm_password', 'require|confirm:password'],
        ['nickname', 'require'],
        ['telephone', 'number|length:11'],
        ['level', 'require'],
        ['status', 'require'],
    ];

    protected $message = [
        'avatar.require'           => '请选择用户头像',
        'username.require'         => '请填写用户名',
        'username.length'          => '用户名长度小于6位或大于18位',
        'username.unique'          => '用户名已存在',
        'password.require'         => '请填写密码',
        'password.length'          => '密码长度小于6位或大于18位',
        'confirm_password.require' => '请填写确认密码',
        'confirm_password.confirm' => '确认密码不一致',
        'nickname.require'         => '请填写昵称',
        'telephone.number'         => '请填写手机号码',
        'telephone.length'         => '请填写正确手机号码',
        'level.require'            => '请选择用户组',
        'status.require'           => '请选择用户状态',
    ];

    protected $scene = [
        'create' => ['avatar', 'username', 'password', 'confirm_password', 'telephone', 'level', 'status'],
        'update' => ['username', 'telephone', 'level', 'status'],
    ];
}